//
// C++ Interface: gimageviewer
//
// Description: 
//
//
// Author: Grzegorz Latarowski <grzesiek@grzesiek>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef GIMAGEVIEWER_H
#define GIMAGEVIEWER_H


// Qt
#include <QWidget>
class QLabel;
class QScrollArea;
class QToolButton;
class QTabWidget;
class QScrollBar;





// --------------------------- GImageWidget{} --------------------------------
// ---------------------------------------------------------------------------
class GImageWidget : public QWidget
{
	Q_OBJECT
			
public:
	GImageWidget( QWidget * pParent = 0, Qt::WindowFlags flags = 0 );
	~GImageWidget() {}
	
	double scale()const { return _scale; }
	const QPixmap * pixmap()const;
	double fitInWindowScale();
	bool isFitInWindow()const { return _fitInWindow; }
	
public slots:
	void scaleImage( const double factor );
	void setScale( const double scale );
	void setFitInWindow( bool fit );
	void setPixmap( const QPixmap & pixmap );
	
protected:
	void adjustScrollBar( QScrollBar * pScrollBar, double scale );
	virtual void resizeEvent( QResizeEvent * pEvent );
	
private:
	QLabel      * _pLabelImage;
	QScrollArea * _pScrollArea;
	
	double _scale;
	bool   _fitInWindow;
	
}; // class !GImageWidget
// ---------------------------------------------------------------------------




// ---------------------------- GImageViewer{} -------------------------------
// ---------------------------------------------------------------------------
class GImageViewer : public QWidget
{
	Q_OBJECT
			
public:
	GImageViewer( QWidget * pParent = 0, Qt::WindowFlags flags = 0 );
	~GImageViewer() {}
	
	bool isScaleLocked()const { return _scaleLocked; }

	
public slots:
	void addPixmap( const QPixmap & pixmap,
					const QString & label = tr( "Image" )
				  );
	void setPixmap( const QPixmap & pixmap,
					const QString & label = tr( "Image" ),
					const int index = -1
				  );
	void removePixmap( const int index = -1 );
	
	void zoomIn( const int index = -1 );
	void zoomOut( const int index = -1 );
	void zoomOriginalSize( const int index = -1 );
	void zoomFitInWindow( bool fit, const int index = -1 );
	void setScale( const double scale, const int index = -1 );
	
	void setScaleLocked( bool l );
	void setScaleUnlocked( bool u );
	
protected slots:
	void currentTabChanged( int index );
	
private:
	QToolButton * _pToolZoomIn;
	QToolButton * _pToolZoomOut;
	QToolButton * _pToolZoomOriginalSize;
	QToolButton * _pToolZoomFitInWindow;
	
	QTabWidget  * _pTabImages;
	
	bool _scaleLocked;
	
}; // class !GImageViewer
// ---------------------------------------------------------------------------



#endif // !GIMAGEVIEWER_H

// eof
